package com.wq.httpclientcore.entities.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @author wangqi
 * @since 2025-03-18 09:05:42
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName(value = "db_query_config", autoResultMap = true)
@Schema(description = "数据库查询配置")
public class DbQueryConfig implements Serializable {

    @TableId("id")
    @Schema(description = "主键，自增 ID，用于唯一标识每个查询配置")
    private Long id;

    @TableField("db_connection_id")
    @Schema(description = "关联的数据库连接配置 ID")
    private Long dbConnectionId;

    @TableField(exist = false)
    @Schema(description = "关联的数据库连接配置")
    private DbConnectionConfig dbConnectionConfig;

    @TableField("query_name")
    @Schema(description = "查询配置的名称，用于业务逻辑区分")
    private String queryName;

    @TableField("query_sql")
    @Schema(description = "要执行的 SQL 查询语句")
    private String querySql;

    @TableField("created_at")
    @Schema(description = "创建时间，默认值为当前时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createdAt;

    @TableField("updated_at")
    @Schema(description = "更新时间，默认值为当前时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updatedAt;


}
